#ifndef _CFIFO_H_
#define _CFIFO_H_
 
#ifdef __cplusplus
extern "C" {
#endif
 
/* USER CODE BEGIN Includes */
#include "main.h"
#include "FreeRTOS.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
/* USER CODE END Includes */
 
/* USER CODE BEGIN Private defines */

typedef struct
{
    void *( *malloc_fn)(size_t sz);
    void ( *free_fn)(void *ptr);
} CFIFO_Hooks;
 
/*环形CFIFO结构体*/
typedef struct
{
    int16_t headPos;          //环形CFIFO头指针
    int16_t tailPos;          //环形CFIFO尾指针
    uint8_t* pBuff;          //环形CFIFO缓存区指针
    int16_t buffLength;     //环形CFIFO缓存区长度
}CFIFO_TypeDef;

/* USER CODE END Private defines */
 
 
/* USER CODE BEGIN Prototypes */
void CFIFO_Init(CFIFO_TypeDef* hcfifo, uint16_t buffLength);
void CFIFO_DeInit(CFIFO_TypeDef* hcfifo);
int16_t CFIFO_Get_FreeSpace(CFIFO_TypeDef* hcfifo);
int16_t CFIFO_Write(CFIFO_TypeDef* hcfifo, uint8_t* pData, uint16_t dataLength);
int16_t CFIFO_Get_AvailableData(CFIFO_TypeDef* hcfifo);
int16_t CFIFO_Read(CFIFO_TypeDef* hcfifo, uint8_t* pReadBuffer, uint16_t readBufferLength);
uint8_t CFIFO_Peek(CFIFO_TypeDef* hcfifo, uint16_t index);
int16_t CFIFO_Pop(CFIFO_TypeDef* hcfifo, uint16_t dataLength);
int16_t CFIFO_Push(CFIFO_TypeDef* hcfifo, uint16_t dataLength);
/* USER CODE END Prototypes */
 
#ifdef __cplusplus
}
#endif
 
#endif /* _CFIFO_H_ */
 
 